{include file="public/header" /}
<link rel="stylesheet" href="/static/index/css/vant.css">
<style>
    .addSex {
        height: 100%;
    }
</style>
<body class="bgc">
<div class="header">
    <i class="layui-icon layui-icon-left" onclick="load_href('{:url(\'user/index\')}',2)"></i> 地址管理
</div>
<ul class="address-list" id="address">
    {foreach name="list" item="vo"}
    <li>
        <van-swipe-cell>
            <div class="address-only">
                <div class="flex-layout" onclick="load_href('{:url(\'address/edit\',[\'id\'=>$vo.id])}',2)">
                    <div class="left">{$vo.nickname}　{$vo.tel}
                        {if $vo.default == 1}<p>默认</p>{/if}
                    </div>
                    <img src="/static/index/img/update.png" alt="">
                </div>
                <div>{$vo.p?$vo.p.title:''}{$vo.c?$vo.c.title:''}{$vo.d?$vo.d.title:''}{$vo.details}</div>
            </div>
            <template #right>
                <van-button square type="danger" text="删除" data-id="{$vo.id}" class="addSex delete-button" />
            </template>
        </van-swipe-cell>
    </li>
    {/foreach}
</ul>
<p class="save save-fixed" onclick="load_href('{:url(\'address/add\')}',2)">+ 添加收货地址</p>
</body>
{include file="public/footer" /}
<script src="/static/index/js/vue.js"></script>
<script src="/static/index/js/vant.js"></script>
<script>
    $(function () {
        new Vue({
            el: "#address",
            methods: {},
        });
        $('.delete-button').click(function (e) {
            layer.confirm('确定要删除当前地址吗？', {title: '请确认'}, function () {
                _ajax('{:url("address/delete")}', {id: e.currentTarget.dataset.id});
            });
        });
    });
</script>
</html>